package Offer2017;

/**
 * 合并两个排序的列表
 * Created by 雷文康 on 2017/12/31.
 */
public class Test17 {

    public static ListNode mergeList(ListNode head1 , ListNode head2){
        if (head1 == null) {
            return  head2;
        }
        if (head2 == null){
            return head1;
        }
        ListNode head;
        if (head1.value < head2.value){
            head = head1;
            head.next = mergeList(head1.next, head2);
        } else {
            head = head2;
            head.next = mergeList(head1, head2.next);
        }
        return head;
    }
}
